layui.use('table', function(){
    var table = layui.table;
    //展示已知数据
    table.render({
        elem: '#filldetailstable'
        ,cols: [[ //标题栏
            {field: 'id', title: 'ID', width: 80, sort: true,rowspan:'2'}
            ,{field: 'username', title: '类别', minWidth: 250,templet: '#typeTpl',rowspan:'2'}
            ,{field: 'experience', title: '总收入', edit: 'text',align:'center',rowspan:'2'}
            ,{ title: '', colspan:'3',align:'center'}
            ,{field: 'experience', title: '总支出', edit: 'text',align:'center',rowspan:'2'}
            ,{ title: '', colspan:'3',align:'center'}
        ],[
            {field: 'sign', title: '财政补助收入', edit: 'text'}
            ,{field: 'sex', title: '上级补助收入', edit: 'text'}
            ,{field: 'city', title: '业务事业收入', edit: 'text'}
            ,{field: 'sign', title: '财政补助支出', edit: 'text'}
            ,{field: 'sex', title: '上级补助支出', edit: 'text'}
            ,{field: 'city', title: '业务事业支出', edit: 'text'}
        ]]
        ,data: [
            {
                "id": "10001"
                ,"username": "医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":1
            }, {
                "id": "10002"
                ,"username": "  综合医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":2
            }, {
                "id": "10003"
                ,"username": "  中西医结合医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":2
            }, {
                "id": "10004"
                ,"username": "  专科医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":2
            }, {
                "id": "10005"
                ,"username": "   口腔医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":3
            }, {
                "id": "10006"
                ,"username": "   眼科医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":3
            }, {
                "id": "10007"
                ,"username": "肿瘤医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":3
            }, {
                "id": "10008"
                ,"username": "心血管病医院"
                ,"email": "130"
                ,"sex": "20"
                ,"city": "30"
                ,"sign": "100"
                ,"experience": "116"
                ,"ip": "192.168.0.8"
                ,"logins": "108"
                ,"joinTime": "2016-10-14"
                ,"level":3
            }
        ]
        //,skin: 'line' //表格风格
        ,even: true
        //,page: true //是否显示分页
        //,limits: [5, 7, 10]
        //,limit: 5 //每页默认显示的数量
    });

    //监听单元格编辑
    table.on('edit(filldetailstable)', function(obj){
        console.log(obj);
        var value = obj.value //得到修改后的值
            ,data = obj.data //得到所在行所有键值
            ,field = obj.field; //得到字段
        layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
    });
});